import Vue from 'vue'

import {Tooltip} from "view-design";

let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 40,
  currentPage: 1
};


let data={
  employeeTerminalList:[],
}

let status={
  actionModal:{
    isShow:false,
    title:'',
  },
  modifyModal:{
    isShow:false,
    isLoading:true,
    title:'',
    content:'',
  },
  decryptedModal:{
    isShow:false,
  },
  employeeTerminalRules:{
    borwerFinger: [
      {required: true, message: '浏览器指纹不能为空', trigger: 'blur'}
    ],
    borwerName: [
      {required: true, message: '浏览器名称不能为空', trigger: 'blur'}
    ],
    terminalNo:[
      {required: true, message: '电脑编号不能为空', trigger: 'blur'}
    ],

  }
};
let params={
  deleteEmployeeTerminalId:"",
  searchParams:{
    keyWord:"",
  },
  datePickerOption:{
    shortcuts: [
      {
        text: '一小时后',
        value () {
          const date = new Date();
          date.setTime(date.getTime() + 3600 * 1000);
          return date;
        },
        onClick: (picker) => {
          this.$Message.info('Click today');
        }
      },
      {
        text: '一天后',
        value () {
          const date = new Date();
          date.setTime(date.getTime() + 3600 * 1000 * 24);
          return date;
        },
        onClick: (picker) => {
          this.$Message.info('Click yesterday');
        }
      },
      {
        text: '一周后',
        value () {
          const date = new Date();
          date.setTime(date.getTime() + 3600 * 1000 * 24 * 7);
          return date;
        },
        onClick: (picker) => {
          this.$Message.info('Click a week ago');
        }
      },
      {
        text: '一年后',
        value () {
          const date = new Date();
          date.setTime(date.getTime() + 3600 * 1000 * 24 * 365);
          return date;
        },
        onClick: (picker) => {
          this.$Message.info('Click a week ago');
        }
      },
    ]
  },
  chooseTime:[],
  employeeTerminal:{
    id:"",
    employeeId:"",
    employeeName:"",
    terminalId:"",
    terminalNo:"",
    startEndTime: [],
    expireTime:0,
    effectiveTime:0,
    isLongTerm:false
  },
};
let  tableTitles=function (self) {
  var titles =  [

    {
      width: 70,
      type: 'index',
      align: 'center'
    },
    {
      title: '员工名称',
      key: 'employeeName',
      width: 100,
      align: 'center',
    },
    {
      title: '浏览器指纹',
      key: 'borwerFinger',
      width: 200,
      align: 'center',
      render: (h, params) => {
        let hideName = Vue.prototype.$tiyHideUsername(params.row.borwerFinger);
        return (
          <div style="color:#207be5">
            <Tooltip content={params.row.borwerFinger}  transfer>
              {hideName}
            </Tooltip>
          </div>
        );


        return h('div',hideName);
      },


    },
    {
      title: '浏览器',
      key: 'borwerName',
      width: 100,
      align: 'center',
    },
    {
      title: '终端编号',
      key: 'terminalNo',
      width: 150,
      align: 'center',
    },
    {
      title: '终端类型',
      key: 'terminalType',
      width: 150,
      align: 'center',
      render: (h, params) => {
        let terminalName = "电脑";
        if (params.row.terminalType == 1){
          terminalName = "电脑";
        }else if (params.row.terminalType == 2){
          terminalName = "手机";
        }
        return h('div',terminalName);
      },
    },
    {
      title: '有效期',
      key: 'expireTime',
      align: 'center',
      width:200,
      render: (h, params) => {
        if (params.row.effectiveTime == -1 && params.row.expireTime == -1){
          return <div>长期有效</div>
        }else{
          var startTime = params.row.effectiveTime == -1 ? "长期" : self.$tiyBJTime(params.row.effectiveTime);
          var endTime = params.row.expireTime == -1 ? "长期" : self.$tiyBJTime(params.row.expireTime);
          return(
            <div>
              <span>start : {startTime}</span>
              <p>end : {endTime}</p>
            </div>
          );
        }
      },
    },
    {
      title: '创建时间',
      key: 'createtime',
      sortable: 'custom',
      width: 120,
      render: (h, params) => {
        return h('div',self.$tiyBJTime(params.row.createtime));
      },
      align: 'center'
    },
    {
      title: '操作',
      key: 'action',
      align: 'center',
      width:100,
      fixed: 'right',
      render: (h, params) => {
        return h('div', [

          self.$authority('OTHER-2-201')? h('Button', {
            props: {type: 'primary', size: 'small', icon: "ios-create",},
            style: {marginRight: '10px', marginTop: '6px', marginBottom: '6px'},
            on: {
              click: () => {
                self.modify(params.index)
              }
            }
          }, "编辑"):h('span',''),
          self.$authority('OTHER-2-202')?h('Button', {
            props: {type: 'error', size: 'small', icon: "md-trash",},
            style: {marginRight: '10px', marginTop: '6px', marginBottom: '6px'},
            on: {
              click: () => {
                self.deleteAction(params.row.id)
              }
            }
          }, "删除 "):h('span',''),
        ])
      },
    }
  ]
  return self.$authTableTitles(titles) ;
};



export  default  {
  tPage: page,
  tStatus: status,
  tParam: params,
  tData: data,
  listTableTitles:tableTitles,
};
